let util = require('../../../../common/util/util')

Page({
    data: {
        xPageReady : true ,
        list : ''
    },

    onLoad: function (options) {
        this.xInit()
    },

    xInit: async function () {
        let that = this
        
        await wx.cloud.callFunction({
            name: 'consulting_message',
            data: {
                action: "get_send_letter",
                from_openid: ''
            }
        }).then(res => {
            console.log('历史记录' , res.result)
            let data = res.result
            for(var i in data){
                data[i].create_time = util.formatTime_chinese(new Date(data[i].create_time))
            }
            that.setData({
                list : data
            })
        })

        that.setData({
            xPageReady : false
        })
    },

    xToDet: function (e) {
        let params = e.currentTarget.dataset
        wx.navigateTo({
            url: '/subsale/pages/email/back/index?text=' + 
                params.text + // 原邮件内容
                '&quote=' + params.quote + // 回复信息
                '&email_id=' + params.email_id + // 邮件id
                '&from_id=' + params.from_id + // 回复人id
                '&user_id=' + params.user_id + // 用户id
                '&name=' + params.name + // 用户姓名
                '&time=' + params.time // 回复时间
        })
    }
})